package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpSensorinfohistory;
import com.ruoyi.system.service.ISnmpSensorinfohistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 传感器数据Controller
 *
 * @author ruoyi
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/snmp/sensorinfohistory")
public class SnmpSensorinfohistoryController extends BaseController
{
    @Autowired
    private ISnmpSensorinfohistoryService snmpSensorinfohistoryService;

    /**
     * 查询传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpSensorinfohistory snmpSensorinfohistory)
    {
        startPage();
        List<SnmpSensorinfohistory> list = snmpSensorinfohistoryService.selectSnmpSensorinfohistoryList(snmpSensorinfohistory);
        return getDataTable(list);
    }

    /**
     * 导出传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:export')")
    @Log(title = "传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpSensorinfohistory snmpSensorinfohistory)
    {
        List<SnmpSensorinfohistory> list = snmpSensorinfohistoryService.selectSnmpSensorinfohistoryList(snmpSensorinfohistory);
        ExcelUtil<SnmpSensorinfohistory> util = new ExcelUtil<SnmpSensorinfohistory>(SnmpSensorinfohistory.class);
        util.exportExcel(response, list, "传感器数据数据");
    }

    /**
     * 获取传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpSensorinfohistoryService.selectSnmpSensorinfohistoryById(id));
    }

    /**
     * 新增传感器数据
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:add')")
    @Log(title = "传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpSensorinfohistory snmpSensorinfohistory)
    {
        return toAjax(snmpSensorinfohistoryService.insertSnmpSensorinfohistory(snmpSensorinfohistory));
    }

    /**
     * 修改传感器数据
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:edit')")
    @Log(title = "传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpSensorinfohistory snmpSensorinfohistory)
    {
        return toAjax(snmpSensorinfohistoryService.updateSnmpSensorinfohistory(snmpSensorinfohistory));
    }

    /**
     * 删除传感器数据
     */
    @PreAuthorize("@ss.hasPermi('snmp:sensorinfohistory:remove')")
    @Log(title = "传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpSensorinfohistoryService.deleteSnmpSensorinfohistoryByIds(ids));
    }
}
